

<?php 	
if(isset($_SESSION["clientdownload"]) && $_SESSION["clientdownload"] != "")
{

        echo "<div id=\"BodyMain\">";
	$dirPath = $_SESSION["clientdownload"]."/downloads/";
	// open the specified directory and check if it's opened successfully
	if ($handle = opendir($dirPath)) 
	{
	echo "<h2 class=\"header1\">".$_SESSION['clientname']."</h2>";
	   // keep reading the directory entries 'til the end
	   while (false !== ($file = readdir($handle))) 
	   {

	      // just skip the reference to current and parent directory
	      if ($file != "." && $file != "..") 
	      {
		 if (!is_dir("$dirPath/$file") && ! preg_match("/log/", $file)) 
		 {
		    // found a file, do something with it?
		    echo "<a id=\"BodyMain\" href=./download.php?fileName=". $file." >".$file."</a>".round(filesize("$dirPath/$file")/1024,2)." KB &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ".date ("F d Y H:i:s.", filemtime("$dirPath/$file"))."<br>";
		 }
	      }
	   }
	   // ALWAYS remember to close what you opened
	   closedir($handle);
	 }
}
elseif(isset($_SESSION["clientdownload"]) && $_SESSION["clientdownload"] == "")
{
	echo "<h2 class=\"header1\">system has not been configured for you to download files.</h2>";
}
else
{
	echo "<h2 class=\"header1\">Configuration Error.</h2>";
}

//Underbar Quickfix
echo "<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/></div>"
?>
